﻿<phone:PhoneApplicationPage
    x:Class="Sinergija13.WP7App.Views.SpeakerListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:b="clr-namespace:Sinergija13.WP7App.Infrastructure.Behaviours"
    xmlns:prismInteractivity="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    xmlns:prismInteractionRequest="clr-namespace:Microsoft.Practices.Prism.Interactivity.InteractionRequest;assembly=Microsoft.Practices.Prism.Interactivity"
    xmlns:behaviours="clr-namespace:Sinergija13.WP7App.Infrastructure.Behaviours"
    xmlns:delay="clr-namespace:Delay"
    xmlns:converters="clr-namespace:Sinergija13.WP7App.Infrastructure.Converters"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False"
    
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="White"
    
    Style="{StaticResource TransitionPageStyle}"
    
    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=SpeakerListViewModel}"
    
    toolkit:TiltEffect.IsTiltEnabled="True">

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding PageLoadedCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <!--Resources-->
    <phone:PhoneApplicationPage.Resources>
        <converters:GroupToBrushValueConverter x:Key="GroupToBrushValueConverter"/>

        <DataTemplate x:Key="trackItemTemplate">
            <Grid Width="50" Margin="0,0,6,6">
                <Grid.Background>
                    <SolidColorBrush Color="{Binding Color}"/>
                </Grid.Background>
                <TextBlock Text="{Binding Code}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Margin="0,-2,0,0"/>     
            </Grid>
        </DataTemplate>

        <!-- The group header template, for groups in the main list -->
        <DataTemplate x:Key="speakersGroupHeader">
            <Border Background="Transparent" Margin="0,20,0,20">
                <Border Background="{StaticResource PhoneAccentBrush}" Width="75" Height="75" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding Key}" 
                                           Foreground="White" 
                                           Style="{StaticResource PhoneTextExtraLargeStyle}"
                                           VerticalAlignment="Center" HorizontalAlignment="Left"/>
                </Border>
            </Border>
        </DataTemplate>

        <!-- The template for groups when they are items in the "jump list". Not setting -->
        <!-- the GroupItemTemplate property will disable "jump list" functionality. -->
        <DataTemplate x:Key="groupItemTemplate">
            <Border Background="{Binding Converter={StaticResource GroupToBrushValueConverter}}" Width="99" Height="99" Margin="6" IsHitTestVisible="{Binding HasItems}">
                <TextBlock Text="{Binding Key}" 
                                       FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                       FontSize="36"
                                       Margin="{StaticResource PhoneTouchTargetOverhang}"
                                       Foreground="White"                                        
                                       VerticalAlignment="Bottom"/>
            </Border>
        </DataTemplate>
        
        <DataTemplate x:Key="speakerItemTemplate">
            <Grid Margin="{StaticResource PhoneTouchTargetOverhang}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Orientation="Horizontal">
                    <delay:PlaceImage Width="110" Height="110" PlaceholderSource="/Sinergija13.WP7App;component/Resources/Images/speaker-no-pic.png" Source="{Binding Picture}" VerticalAlignment="Top"/>
                    <StackPanel Grid.Column="1" VerticalAlignment="Top">
                        <TextBlock Text="{Binding FullName}" Style="{StaticResource PhoneTextLargeStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="12,-12,12,6" Foreground="White"/>
                        <TextBlock Text="{Binding Company}" MaxWidth="220" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Foreground="White"/>                   
                    </StackPanel>
                </StackPanel>
                <ItemsControl Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" ItemTemplate="{StaticResource trackItemTemplate}" ItemsSource="{Binding Tracks}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Tap">
                        <i:InvokeCommandAction Command="{Binding Path=DataContext.SpeakerSelectedCommand, ElementName=speakers}" CommandParameter="{Binding}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Grid>
        </DataTemplate>

    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="/Sinergija13.WP7App;component/Resources/Images/Background3.jpg"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="Sinergija 13" Style="{StaticResource PhoneTextNormalStyle}" Foreground="White"/>
            <TextBlock Text="predavači" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Foreground="White"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <toolkit:LongListSelector x:Name="speakers"
                    ItemsSource="{Binding Speakers}"                     
                    GroupHeaderTemplate="{StaticResource speakersGroupHeader}"
                    GroupItemTemplate="{StaticResource groupItemTemplate}"
                    ItemTemplate="{StaticResource speakerItemTemplate}">
                <toolkit:LongListSelector.GroupItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </toolkit:LongListSelector.GroupItemsPanel>
            </toolkit:LongListSelector>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>